[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
eof(FILEHANDLE)
eof()
eof Returns 1 if the next read on FILEHANDLE will return
end of file, or if FILEHANDLE is not open. FILEHAN-
DLE may be an expression whose value gives the real
filehandle name. (Note that this function actually
reads a character and then ungetc's it, so it is not
very useful in an interactive context.) An eof
without an argument returns the eof status for the
last file read. Empty parentheses () may be used to
indicate the pseudo file formed of the files listed
on the command line, i.e. eof() is reasonable to use
inside a while (<>) loop to detect the end of only
the last file. Use eof(ARGV) or eof without the
parentheses to test EACH file in a while (<>) loop.
Examples:
# insert dashes just before last line of last file
while (<>) {
if (eof()) {
print "--------------\n";
}
print;
}
# reset line numbering on each input file
while (<>) {
print "$.\t$_";
if (eof) { # Not eof().
close(ARGV);
}
}
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson